home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-04
/
rexxutil.zip
/
RXLIBMGR.CMD
< prev
Wrap
OS/2 REXX Batch file
|
1990-10-02
|
11KB
|
309 lines
/** REXX **************************************************************/
/* */
/* Function Name: RXLIBMGR */
/* */
/* Description: Maintains Rexx Macrospace libraries. */
/* */
/* Author: W. David Ashley */
/* */
/* Version: 1.0 */
/* */
/* */
/**********************************************************************/
/* Check for correct number of input arguments */
if arg() \= 1 then do
say 'Error: Incorrect input arguments.'
say
say 'Syntax: REXMACRO [d:[path]]filename.ext'
exit
end
if length(arg(1)) < 3 then do
say 'Error: Incorrect input arguments.'
say
say 'Syntax: REXMACRO [d:[path]]filename.ext'
exit
end
arg file
/* Make REXXUTIL.DLL library functions available */
if rxfuncquery('RexMacroLoad') = 1 then ,
call rxfuncadd 'RexMacroLoad', 'REXXUTIL', 'RexMacroLoad'
if rxfuncquery('RexMacroSave') = 1 then ,
call rxfuncadd 'RexMacroSave', 'REXXUTIL', 'RexMacroSave'
if rxfuncquery('RexMacroErase') = 1 then ,
call rxfuncadd 'RexMacroErase', 'REXXUTIL', 'RexMacroErase'
if rxfuncquery('RexMacroQuery') = 1 then ,
call rxfuncadd 'RexMacroQuery', 'REXXUTIL', 'RexMacroQuery'
if rxfuncquery('RexMacroDrop') = 1 then ,
call rxfuncadd 'RexMacroDrop', 'REXXUTIL', 'RexMacroDrop'
if rxfuncquery('RexMacroReOrder') = 1 then ,
call rxfuncadd 'RexMacroReOrder', 'REXXUTIL', 'RexMacroReOrder'
if rxfuncquery('RexRead') = 1 then ,
call rxfuncadd 'RexRead', 'REXXUTIL', 'RexRead'
if rxfuncquery('RexDelete') = 1 then ,
call rxfuncadd 'RexDelete', 'REXXUTIL', 'RexDelete'
/* Read input file */
retc = RexRead(file, 'fline')
if retc \= 0 then do
select
when retc = 1 then do
say 'Error: Cannot open input file' file'.'
exit
end
when retc = 2 then do
say 'Error: Out of memory or memory error.'
exit
end
when retc = 5 then do
say 'Error: Internal REXXUTIL error. Contact REXXUTIL programmer.'
exit
end
otherwise do
say 'Error: Unknown error. Contact REXXUTIL programmer.'
exit
end
end
end
if fline.0 = 0 then do
say 'Error: Input file is empty.'
exit
end
/* Save the current Rexx macrospace */
retc = RexMacroSave('temp.rxl')
if retc > 0 then do
temp_saved = 'NO'
if retc > 2 then do
say 'Error: Could not save current Macrospace.'
exit
end
end
else temp_saved = 'YES'
call RexMacroErase
/* We are now ready to process the input file */
cmd = ''
parm1 = ''
parm2 = ''
parm3 = ''
do i = 1 to fline.0
/* Process a line of the input file */
parse upper value fline.i with cmd parm1 parm2 parm3
select
when cmd = 'LOAD' then call loadfile parm1, parm2, parm3
when cmd = 'DROP' then call dropfunc parm1
when cmd = 'REORDER' then call reorder parm1, parm2
when cmd = 'SAVE' then call savefile parm1
otherwise do
say 'Error: Invalid command in input file' file'.'
call Reload
exit
end
end
end
/* reset Rexx macrospace to original form */
call Reload
/* exit function */
return
/**********************************************************************/
/* */
/* Function Name: Loadfile() */
/* */
/* Description: Load a Rexx Macrospace library into the Macrospace*/
/* */
/**********************************************************************/
Loadfile: procedure expose i
if arg() = 3 then do
retc = RexMacroLoad(arg(1), arg(2), arg(3))
end
else if arg() = 1 then do
retc = RexMacroLoad(arg(1))
end
else do
say 'Error: Line 'i' of input file.'
say ' Incorrect number of arguments to function Loadfile().'
call Reload
exit
end
select
when retc = 0 then do
if arg() = 3 then,
say 'Function 'arg(2)' successfully loaded to macrospace.'
else,
say 'Library 'arg(1)' successfully loaded to macrospace.'
end
when retc = 1 then do
say 'Error: Line 'i' of input file.'
say ' No Macro storage space available.'
call Reload
exit
end
when retc = 2 then do
say 'Warning: Line 'i' of input file.'
say ' Function not found.'
end
when retc = 4 then do
say 'Warning: Line 'i' of input file.'
say ' Function(s) already exist in macrospace.'
say ' Function(s) not loaded to macrospace.'
end
when retc = 5 then do
say 'Error: Line 'i' of input file.'
say ' Macro file error.'
call Reload
exit
end
when retc = 6 then do
say 'Error: Line 'i' of input file.'
say ' Macro library file signature error.'
call Reload
exit
end
when retc = 7 then do
say 'Error: Line 'i' of input file.'
say ' Function source not found.'
call Reload
exit
end
when retc = 8 then do
say 'Error: Line 'i' of input file.'
say ' Invalid search position.'
call Reload
exit
end
otherwise do
say 'Error: Line 'i' of input file.'
say ' Unknown error. Contact REXXUTIL programmer.'
call Reload
exit
end
end
return
end
/**********************************************************************/
/* */
/* Function Name: Savefile() */
/* */
/* Description: Save a Rexx Macrospace to a file */
/* */
/**********************************************************************/
Savefile: procedure expose i
retc = RexMacroSave(arg(1))
select
when retc = 0 then do
say 'Macrospace saved to library file' arg(1)'.'
end
when retc = 2 then do
say 'Warning: Line 'i' of input file.'
say ' Macro function(s) not found.'
end
when retc = 3 then do
say 'Warning: Line 'i' of input file.'
say ' Extension required on Macro Library filename.'
say ' Macrospace not saved.'
end
when retc = 5 then do
say 'Error: Line 'i' of input file.'
say ' Macro file error.'
call Reload
exit
end
otherwise do
say 'Error: Line 'i' of input file.'
say ' Unknown error. Contact REXXUTIL programmer.'
call Reload
exit
end
end
return
end
/**********************************************************************/
/* */
/* Function Name: Dropfunc() */
/* */
/* Description: Drop a function from the Rexx macrospace */
/* */
/**********************************************************************/
Dropfunc: procedure expose i
retc = RexMacroDrop(arg(1))
select
when retc = 0 then do
say 'Function' funcname 'successfully dropped.'
end
when retc = 2 then do
say 'Warning: Line 'i' of input file.'
say ' Macro function(s) not found.'
end
otherwise do
say 'Error: Line 'i' of input file.'
say ' Unknown error. Contact REXXUTIL programmer.'
call Reload
exit
end
end
return
end
/**********************************************************************/
/* */
/* Function Name: Reorder() */
/* */
/* Description: Reorder macrospace function */
/* */
/**********************************************************************/
Reorder: procedure expose i
retc = RexMacroReOrder(arg(1), arg(2))
select
when retc = 0 then do
say 'Function' arg(1) 'successfully reorderd.'
end
when retc = 2 then do
say 'Warning: Line 'i' of input file.'
say ' Macro function(s) not found.'
end
when retc = 8 then do
say 'Error: Line 'i' of input file.'
say ' Invalid search position.'
call Reload
exit
end
otherwise do
say 'Error: Line 'i' of input file.'
say ' Unknown error. Contact REXXUTIL programmer.'
call Reload
exit
end
end
return
end
/**********************************************************************/
/* */
/* Function Name: Reload() */
/* */
/* Description: Reload macrospace from temporary file. */
/* */
/**********************************************************************/
Reload: procedure expose temp_saved
call RexMacroErase
if temp_saved = 'YES' then call RexMacroLoad 'temp.rxl'
call RexDelete 'temp.rxl'
return
end